]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
overviewControls: Cache workspaces boxes
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Wed, 10 Feb 2021 21:09:04 +0000 (18:09 -0300)
committerMarge Bot <marge-bot@gnome.org>
Thu, 11 Feb 2021 15:50:31 +0000 (15:50 +0000)
Next commit will need to access the allocated workspaces boxes, so
cache them at allocation time.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>

js/ui/overviewControls.js

index efb3fd9fbf739b7f35aae09f6e12c29e3846d712..94cf2336efa08f93057d6e1f9d1c974e41f13f0d 100644 (file)
@@ -37,6 +37,8 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
         this._viewSelector = viewSelector;
         this._dash = dash;
 
+        this._cachedWorkspaceBoxes = new Map();
+
         stateAdjustment.connect('notify::value', () => this.layout_changed());
     }
 
@@ -140,15 +142,18 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
         let params = [box, searchHeight, dashHeight, thumbnailsHeight];
         const transitionParams = this._stateAdjustment.getStateTransitionParams();
 
+        // Update cached boxes
+        for (const state of Object.values(ControlsState)) {
+            this._cachedWorkspaceBoxes.set(
+                state, this._getWorkspacesBoxForState(state, ...params));
+        }
+
         let workspacesBox;
         if (!transitionParams.transitioning) {
-            workspacesBox =
-                this._getWorkspacesBoxForState(transitionParams.currentState, ...params);
+            workspacesBox = this._cachedWorkspaceBoxes.get(transitionParams.currentState);
         } else {
-            const initialBox =
-                this._getWorkspacesBoxForState(transitionParams.initialState, ...params);
-            const finalBox =
-                this._getWorkspacesBoxForState(transitionParams.finalState, ...params);
+            const initialBox = this._cachedWorkspaceBoxes.get(transitionParams.initialState);
+            const finalBox = this._cachedWorkspaceBoxes.get(transitionParams.finalState);
             workspacesBox = initialBox.interpolate(finalBox, transitionParams.progress);
         }
 
@@ -156,7 +161,7 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
 
         // AppDisplay
         const workspaceAppGridBox =
-            this._getWorkspacesBoxForState(ControlsState.APP_GRID, ...params);
+            this._cachedWorkspaceBoxes.get(ControlsState.APP_GRID);
 
         params = [box, searchHeight, dashHeight, workspaceAppGridBox];
         let appDisplayBox;